package com.example.wlzz.utils;

import java.util.Random;

public class CodeUtil {
    public static String getCode(){
        char[] codeSequence = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
        StringBuffer randomCode = new StringBuffer();
        // 创建一个随机数生成器类
        Random random = new Random();
        for (int i = 0; i < 6; i++) {
            String strRand = String.valueOf(codeSequence[random.nextInt(codeSequence.length-1)]);
            // 将产生的四个随机数组合在一起。
            randomCode.append(strRand);
        }
        String phoneCode  = randomCode.toString();
        return phoneCode;
    }
}
